<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->increments('order_id')->comment("订单ID,自增");
            $table->integer('user_address_id')->unsigned()->comment("地址ID");
            $table->integer('parent_order_id')->unsigned()->comment("父订单ID");
            $table->integer('user_id')->unsigned()->comment("用户ID");
            $table->integer('commodity_id')->unsigned()->comment("商品ID");
            $table->integer('info_id')->unsigned()->comment("规格ID");
            $table->integer('color_id')->unsigned()->comment("颜色ID");
            $table->integer('size_id')->unsigned()->comment("尺码ID");
            $table->integer('number')->unsigned()->comment("数量");
            $table->string('unit_price')->comment("单价");
            $table->string('all_price')->comment("总价");
            $table->tinyInteger('state')->comment("状态");
            $table->timestamps();
            $table->engine = 'InnoDB';
            $table->index('order_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('orders');
    }
}
